#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 505;
const double eps = 1e-5;

int n, m;
double a[N][N];
int select(int i, int c) {
  int res = -1;
  rep(j, i, n) {
    if (abs(a[j][c]) > eps) {
      if (res == -1 || a[res][m + 1] > a[j][m + 1]) res = j;
    }
  }
  if (res == -1) return i;
  return res;
}
void swap_row(int i, int j) { rep(k, 1, m + 1) swap(a[i][k], a[j][k]); }
void normal(int i, int c) {
  double x = a[i][c];
  rep(k, 1, m) a[i][k] /= x;
}
void sub(int k, int i, int c) {
  if (k == i || abs(a[k][c]) < eps) return;
  double x = a[k][c];
  rep(j, 1, m) a[k][j] -= x * a[i][j];
}
void gauss() {
  int i = 1, c = 1;
  while (i <= n && c <= m) {
    int j = select(i, c);
    if (j != i) swap_row(i, j);
    if (abs(a[i][c]) > eps) {
      normal(i, c);
      rep(k, 1, n) sub(k, i, c);
      i++;
    }
    c++;
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  rep(i, 1, n) rep(j, 1, m) cin >> a[i][j];
  rep(i, 1, n) cin >> a[i][m + 1];
  gauss();
  int ans1 = 0, ans2 = 0;
  rep(i, 1, n) {
    int cnt = 0;
    rep(j, 1, m) if (abs(a[i][j]) > eps) cnt++;
    if (cnt) ans1++, ans2 += a[i][m + 1];
  }
  // rep(i, 1, n) rep(j, 1, m) cout << a[i][j] << " \n"[j == m];
  cout << ans1 << ' ' << ans2;
  return 0;
}